package com.sen.ssp.test.action;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * spring mvc演示类。 
 * 命名规则:
 * 
 * (方法名) create, edit[save, update], remove, removeAll, show
 * 
 * Controller(类/路径名) : "/xx/*" => XxController
 * 
 * @author sen
 * 
 */
@Controller
@RequestMapping("/demo/*") // 对整个类的路径定义(也可以分别定义在每个方法中)
public class SpringMvcDemoController {
	
	@RequestMapping("index")
	public String index() {
		return "redirect:/index.jsp";
	}
	
	@RequestMapping("simple")
	@ResponseBody
	public String simple() {
		return "你好，我是simple方法！";
	}
	
	@RequestMapping(value="view", method=RequestMethod.GET)
	public void view(Model model) {
		model.addAttribute("foo", "foo value");
		model.addAttribute("tee", "tee value");
	}
}
